package com.jungle.design.mode.handler;


import org.apache.commons.lang3.StringUtils;

import java.util.HashMap;
import java.util.Map;

/**
 * @author Jungle
 * @create 2024-07-07 23:24
 *   工厂设计模式
 */
public class MyFactory {
    private final static Map<String, MyHandler> STRATEGY_MAP = new HashMap<String, MyHandler>();

    public static MyHandler getInvokeStrategy(String name) {
        return STRATEGY_MAP.get(name);
    }

    public static void register(String str, MyHandler myHandler) {
        if (StringUtils.isEmpty(str) || null == myHandler) {
            return;
        }
        STRATEGY_MAP.put(str, myHandler);
    }
}
